# -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 22:02:16 2020

@author: jules
"""


import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'

###############################################################################


alpha = 5
beta = -2.5

N=6*10**(23)
a=1

def E(alpha,beta,k):
    return alpha +2*beta*np.cos(k*a)

def DOS(alpha, beta,E):
    return N/(np.pi*(4*beta**2-(E-alpha)**2)**(1/2))





    

# Valeurs des températures affichées
k = np.linspace(-np.pi/(a)+0.01,np.pi/(a)-0.01,100000)

# x1(T) et y1(T)
E = E(alpha, beta, k)
DOS = DOS(alpha,beta,E)
Emin = np.min(E)
Emax= np.max(E)
DOSmin = np.min(DOS)
DOSmax=np.max(DOS)
print(DOSmax)
###############################################################################

fig = plt.figure(figsize=(6,5))
ax = fig.add_subplot(211)
ax2 = fig.add_subplot(212)

# Plots de x1,y1 en fonction de T
ax.plot(k, E,'red',lw=4, label = "E(k)")
ax2.plot(DOS, E,'royalblue',lw=4, label = "E(DOS)")

# Légende
ax.legend(loc=2,prop={'size':16})
# Axe x entre 0 et 1
ax.set_xlim(-np.pi/(a),np.pi/(a))
ax2.set_xlim(0, 5*DOSmin)
ax2.set_ylim(0, 10)
# Grille
ax.grid(True)
# Titres des axes
ax.set_xlabel('k', fontsize=20)
ax.set_ylabel('E', fontsize=20)
ax2.set_xlabel('DOS', fontsize=20)
ax2.set_ylabel('E', fontsize=20)

# Taille des nombres sur les axes
ax.tick_params(axis='both', which='major', labelsize=15)

#Titre
ax.set_title("Energie en fonction du vecteur d'onde",fontsize=18)
ax.set_title("Energie en fonction de la densité d'états",fontsize=18)
# Nombres sur l'axe y, et températures en lettres
#Yticks = list(range(1200,1350,20))
#Yticks.append(T1_star); Yticks.append(T2_star)
#Yticks = np.sort(Yticks)
#Ylabels = [elem for elem in Yticks]
#Ylabels[1]=r'$T_t^*$'
#Ylabels[-2]=r'$T_b^*$'
#Ylabels = [str(elem) for elem in Ylabels]
#ax.set_yticks(Yticks)
#ax.set_yticklabels(Ylabels)



plt.tight_layout()


